﻿
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
<!--

#edit
{
    opacity: 0.8;
}   
#edit:hover
{
    opacity: 1;
}
#del
{
    opacity: 0.8;
}
#del:hover
{
    opacity: 1;
}   
#check
{
    opacity: 0.8;
}
#check:hover
{
    opacity: 1;
}
    
-->
</style>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
	<script src="ckeditor/_samples/sample.js" type="text/javascript"></script>
	<link href="ckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />
</head>
<body>


      <?php
				include("code/DataProvider.php");
                $key = $_REQUEST["txtSearchSP"];
                $type = $_REQUEST["search"];
                
                if($type == 1)
                {
                    	$querySP="SELECT sp.MaSP, sp.TenSP, nd.TenDangNhap, sp.SoLuongTon, sp.SoLuongBan, hsx.TenHSX, l.TenLSP, sp.GiaSP, sp.HinhURL, sp.MoTaSP, sp.BiXoa, sp.NgayDang
                FROM sanpham sp, nguoidung nd, hangsx hsx, loaisp l
                WHERE sp.MaND = nd.MaND AND sp.MaLSP = l.MaLSP AND sp.MaHSX = hsx.MaHSX AND sp.TenSP LIKE '%".$key."%'
                ORDER BY NGAYDANG DESC";
                    $result = DataProvider::executeQuery($querySP);
                }
				if($type == 2) // gia, tai khoan, mota
                {
                    $queryGia="SELECT sp.MaSP, sp.TenSP, nd.TenDangNhap, sp.SoLuongTon, sp.SoLuongBan, hsx.TenHSX, l.TenLSP, sp.GiaSP, sp.HinhURL, sp.MoTaSP, sp.BiXoa, sp.NgayDang
                FROM sanpham sp, nguoidung nd, hangsx hsx, loaisp l
                WHERE sp.MaND = nd.MaND AND sp.MaLSP = l.MaLSP AND sp.MaHSX = hsx.MaHSX AND sp.GiaSP LIKE '%".$key."%'
                ORDER BY NGAYDANG DESC";
                    $result = DataProvider::executeQuery($queryGia);
                }
                if($type == 3) // gia, tai khoan, mota
                {
                    $queryND="SELECT sp.MaSP, sp.TenSP, nd.TenDangNhap, sp.SoLuongTon, sp.SoLuongBan, hsx.TenHSX, l.TenLSP, sp.GiaSP, sp.HinhURL, sp.MoTaSP, sp.BiXoa, sp.NgayDang
                FROM sanpham sp, nguoidung nd, hangsx hsx, loaisp l
                WHERE sp.MaND = nd.MaND AND sp.MaLSP = l.MaLSP AND sp.MaHSX = hsx.MaHSX AND nd.TenDangNhap LIKE '%".$key."%'
                ORDER BY NGAYDANG DESC";
                    $result = DataProvider::executeQuery($queryND);
                }
                if($type == 4) // gia, tai khoan, mota
                {
                    $queryMoTa="SELECT sp.MaSP, sp.TenSP, nd.TenDangNhap, sp.SoLuongTon, sp.SoLuongBan, hsx.TenHSX, l.TenLSP, sp.GiaSP, sp.HinhURL, sp.MoTaSP, sp.BiXoa, sp.NgayDang
                FROM sanpham sp, nguoidung nd, hangsx hsx, loaisp l
                WHERE sp.MaND = nd.MaND AND sp.MaLSP = l.MaLSP AND sp.MaHSX = hsx.MaHSX AND sp.MoTa LIKE '%".$key."%'
                ORDER BY NGAYDANG DESC";
                    $result = DataProvider::executeQuery($queryMota);
                }
        ?>
          
            <h2 style="color: blue; text-align: center;">DANH SÁCH SẢN PHẨM</h2>
            <div><a href="admin.php?act=9"> Quay lại </a></div>
            <div style="font-style: italic; color: red;"></div>
            <hr /><br />    
    <table border="1" cellspacing="0" style=" text-align: center; font-size: 10px;">
    	<tr style=" color: white; background: #555;">
            <td align="center" height="30px" width="50">Tên SP</td>
            <td align="center" height="30px" width="65">Người bán</td>
            <td align="center" height="30px" width="25">SL tồn</td>
            <td align="center" height="30px" width="25">SL bán</td>
            <td align="center" height="30px" width="40">HSX</td>
            <td align="center" height="30px" width="40">Loại SP</td>
            <td align="center" height="30px" width="50">Giá</td>
            <td align="center" height="30px" width="65">Hình</td>
            <td align="center" height="30px" width="200">Mô tả</td>
            <td align="center" height="30px" width="25">Bị xóa</td>
            <td align="center" height="30px" width="45">Ngày đăng</td>
            <td align="center" height="30px" width="35">Sửa</td>
            <td align="center" height="30px" width="35">Xóa</td>
        </tr><?php
        while ($row=mysql_fetch_array($result))
			{?>
        <tr>
            <td align="center" ><?php echo $row['TenSP'] ?></td>
            <td align="center" ><?php echo $row['TenDangNhap'] ?></td>
            <td align="center" ><?php echo $row['SoLuongTon'] ?></td>
            <td align="center" ><?php echo $row['SoLuongBan'] ?></td>
            <td align="center" ><?php echo $row['TenHSX'] ?></td>
            <td align="center" ><?php echo $row['TenLSP'] ?></td>
            <td align="center" ><?php echo number_format($row['GiaSP']) ?> VNĐ</td>
            <td align="center" ><?php echo $row['HinhURL'] ?></td>
            <td align="center" ><?php echo $row['MoTaSP'] ?></td>
            <td align="center" ><?php echo $row['BiXoa'] ?></td>
            <td align="center" ><?php echo $row['NgayDang'] ?></td>
            <td align="center" >
                <a href="admin.php?act=10&id=<?php echo $row['MaSP']; ?>">
                    <img id="edit" src="images/edit-icon.png" height="25" width="25"/>   
                </a>
            </td>
            <td align="center">
                <a href="admin.php?act=13=&id=<?php echo $row['MaSP']; ?>">
                <?php
                    if($row['BiXoa'] == 1)
                        echo '<img id="check" src="images/check-icon.png" height="25" width="25"/>';
                    else
                        echo '<img id="del" src="images/delete-icon.png" height="25" width="25"/>';

                ?>  
                </a>
            </td>
        </tr><?php } ?>
	</table>	
				
		       </td>
  </tr>
</table>


</body>
</html>

